<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<?php 
	if( !isset($_COOKIE["username"]) ){
		echo "<script>window.location.href='login.php'</script>";
	}else{
		setcookie("username", $_COOKIE["username"],time() + 900);
	}
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Fee Demand</title>
<link href="css/template.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/OperateTool.js"></script>
<script src="js/droplinemenu.js" type="text/javascript"></script>
<script src="js/search.js" type="text/javascript"></script>
<script type="text/javascript">
//build menu with DIV ID="myslidemenu" on page:
droplinemenu.buildmenu("nav");
</script>


<link href="css/ui-lightness/jquery-ui-1.9.2.custom.css" rel="stylesheet">
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script src="js/jquery-ui-1.9.2.custom.js"></script>


<script src="js/search.js"></script>

<style type="text/css">
	#bodyTable td, #bodyTable th{
		/*background-color:#ffffff;
		border:solid 1px #a0c6e5;
		rules:cols;*/
	}
	#headTable td, #headTable th{
		/*background-color:#ffffff;
		border:solid 1px #a0c6e5;*/
	}
</style>


<script type="text/javascript">

	function printFeeDemand(){
		document.getElementById("header").style.display = "none";
		document.getElementById("nav").style.display = "none";
		document.getElementById("headerTitle").style.display = "none";
		document.getElementById("operateDiv").style.display = "none";
		window.print();
		document.getElementById("header").style.display = "block";
		document.getElementById("nav").style.display = "block";
		document.getElementById("headerTitle").style.display = "block";
		document.getElementById("operateDiv").style.display = "block";
		
	}
</script>

</head>
<body>
	<div id="container">
		<div id="header"></div>
		<?php include_once 'nav.php';?>
		<div id="main_content" >
			<div id="headTableDiv" style="margin:55px auto 20px;width:1000px;">
				<table id="headTable" style="border:1px;border-color:#a0c6e5;border-collapse:collapse;width:85%;margin:0px auto;">
					<tr>
						<td rowspan="2" style="text-align:center;background-color:#f4f4f4;border-top:solid 1px #e6e6e6;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6;"><label>Dr. Geraldine Morrow</label></td>
						<td colspan="2" style="border-right:solid 1px #e6e6e6;border-top:solid 1px #e6e6e6;"><label>Clinic Details: </label></td>
					</tr>
					<tr>
						<td></td>
						<td style="border-right:solid 1px #e6e6e6;"><label>•	Mount Carmel Hospital, Dublin 14</label></td>
					</tr>
					<tr>
						<td style="width:40%;text-align:center;background-color:#f4f4f4;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6;"><label>Consultant Dermatologist</label></td>
						<td style="width:10%"></td>
						<td style="width:50%;border-right:solid 1px #e6e6e6;"><label>•	Beacon Consultants Clinic, Sandyford, Dublin 18</label></td>
					</tr>
					<tr>
						<td style="text-align:center;background-color:#f4f4f4;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6;"><label>M.B., B.Ch., B.A.O., M.R.C.P.I.</label></td>
						<td></td>
						<td style="border-right:solid 1px #e6e6e6;">•	Vista Clinic, Naas, Co. Kildare. </td>
					</tr>
					<tr>
						<td style="height:12px;background-color:#f4f4f4;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6;"></td>
						<td style="border-right:solid 1px #e6e6e6;" colspan="2">&nbsp;&nbsp;&nbsp;HLC at DCU (Collins Avenue)</td>
					</tr>
					<tr>
						<td rowspan="2" style="text-align:center;background-color:#e6e6e6;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6;border-top:solid 1px #e6e6e6;">www.geraldinemorrow.com</td>
						<td style="height:12px;background-color:#e6e6e6;border-top:solid 1px #e6e6e6;"></td>
						<td style="background-color:#e6e6e6;border-top:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6;"></td>
	
					</tr>
					<tr>
						<td colspan="2" style="background-color:#e6e6e6;border-right:solid 1px #e6e6e6;"><label>All Correspondence to:       39 Grosvenor Road,  Rathmines,  D6</label></td>
	
					</tr>
					<tr>
						<td rowspan="2" style="text-align:center;background-color:#e6e6e6;border-left:solid 1px #e6e6e6;border-right:solid 1px #e6e6e6;border-bottom:solid 1px #e6e6e6;">Medical Council  Reg. No. 09981</td>
						<td colspan="2" style="background-color:#e6e6e6;border-right:solid 1px #e6e6e6;"><label>Phone :   01-4970392          Fax.:  01-4974119</label></td>
	
					</tr>
					<tr>
						<td colspan="2" style="background-color:#e6e6e6;border-right:solid 1px #e6e6e6;border-bottom:solid 1px #e6e6e6;"><label>e-mail:     dermatology.secretary@gmail.com   </label></td>
	
					</tr>
				</table>
			</div>
			<?php 
				$ini_array = parse_ini_file("config/config.ini");
				
				$conn = @mysqli_connect($ini_array["host"], $ini_array["username"], $ini_array["password"], $ini_array["db_name"]) or die("cann't connect the mysql db");
				mysqli_set_charset($conn, "utf8");
				ini_set('default_charset', "UTF-8");
				date_default_timezone_set($ini_array["default_timezone"]);
				
				$patientNo = "";
				$patientName = "";
				$patientAddress = "";
				$seenDate = "";
				$fee = "";
				
				if( isset($_GET["appointmentNo"]) &&  preg_match("/^\d+$/", $_GET["appointmentNo"]) == true ){
					$appointmentNo = $_GET["appointmentNo"];
					$getInfoSql = "select visit.Patient_no, First_name, Surname, address, Datetime_patient_seen, Professional_fee, isPay from visit left outer join patient on patient.Patient_no = visit.Patient_no where Appointment_no=$appointmentNo";
					$infoResult = mysqli_query($conn, $getInfoSql);
					if( $row = mysqli_fetch_array($infoResult)){
						$patientNo = $row["Patient_no"];
						$patientName = $row["First_name"]." ".$row["Surname"];
						$patientAddress = $row["address"];
						$seenDate = date("d/m/Y", strtotime($row["Datetime_patient_seen"]));
						$fee = $row["Professional_fee"];
						$isPay = $row["isPay"];
						
						if( $isPay == 1 ){
							echo "<script>alert('this record is payed!');window.location.href='list_unpaid.php'</script>";
						}
						
					}else{
						echo $getInfoSql;
						echo "<script>alert('appointment No. was not found!');window.location.href='list_unpaid.php'</script>";
					}
					
				}else{
					echo "<script>alert('No appointment No.');window.location.href='list_unpaid.php'</script>";
				}
				
			?>
			<div style="margin:40px auto 15px;width:1000px;">
				<table id="bodyTable" style="margin:0px auto;border:1;border-color:#a0c6e5;border-collapse:collapse;width:85%;">
					<tr>
						<td colspan="3" >To:<?php echo " ".$patientName?></td>					
					</tr>
					<tr>
						<td></td>
						<td colspan="2"><?php echo $patientAddress;?></td>					
					</tr>
					<tr>
						<td colspan="2">Ref. No.: <?php echo $patientNo?></td>
						<td style="text-align:right;"><div style="position:relative;right:10px;">Date:<?php echo date("d/m/Y");?></div></td>
					</tr>
					<tr>
						<td style="height:35px;width:85px;"></td>
						<td style="width:85px;"></td>
						<td></td>
					</tr>
					<tr>
						<td colspan="3"> I would be grateful if you would settle your outstanding bill for consultation with Dr. Morrow as detailed below. Please send Cheque / Postal Order to our correspondence address (39 Grosvenor Road, Rathmines, Dublin 6). If you have already paid this bill please contact my secretary at 01-4970392 between 9.30 am and 5pm (Monday - Friday).</td>
					</tr>
					<tr>
						<td style="height:45px;"></td>
						<td></td>
						<td></td>
					</tr>
					<tr>
						<td colspan="2" >Date of Consultation:  </td>
						<td><?php echo $seenDate?></td>
					</tr>
					<tr>
						<td colspan="2">Fee Outstanding: </td>
						<td><?php echo $fee?></td>
					</tr>
	
	
				</table>
			</div>
			<div>
				<img src="./picture/signature.png" style="position:relative;left:800px;"/>
			</div>
			<div id="operateDiv" style="text-align:center;">
				<input type="button" value="print" onclick="printFeeDemand()"/>
				<input type="button" value="return" onclick="window.location.href='list_unpaid.php'" />
			</div>
		</div>
	</div>


</body>


</html>
